package com.bensonbasement.snorflux.memory;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class RWorld implements Serializable {
	
	private final Memory memory;
	private final Map<Long,RWorldElement> worldElementMap;
	private final Map<Integer,RLevel> levelMap;
	
	public RWorld(Memory memory) {
		this.memory = memory;
		this.worldElementMap = new HashMap<Long,RWorldElement>();
		this.levelMap = new HashMap<Integer,RLevel>();
	}
	
	public Memory getMemory() {
		return memory;
	}
	
	/**
	 * This should only be called by the RLevel constructor.
	 * @param level
	 */
	public void addLevel(RLevel level) {
		this.levelMap.put(level.getLevelNum(), level);
	}
	
	/**
	 * This should only be called by the RWorldElement constructor.
	 * @param element
	 */
	public void storeWorldElement(RWorldElement element) {
		this.worldElementMap.put(element.getWorldElementID(), element);
	}
	
	public RLevel getLevel(int levelNum) {
		return this.levelMap.get(levelNum);
	}
	
	public RWorldElement getWorldElement(long worldElementID) {
		return this.worldElementMap.get(worldElementID);
	}
	
	public void deleteWorldElement(long worldElementID) {
		this.worldElementMap.remove(worldElementID);
	}
	
	
	// TEMPORARY
	public Map<Integer, RLevel> getLevelMap() {
		return levelMap;
	}
}
